//
//  ViewController.m
//  DEMO
//
//  Created by J on 16/4/3.
//  Copyright © 2016年 J. All rights reserved.
//

#import "ViewController.h"
#import "UMSocial.h"
#import "UMSocialWechatHandler.h"
@interface ViewController ()<UMSocialUIDelegate>

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)qq:(id)sender {
    
    [UMSocialSnsService presentSnsIconSheetView:self
                                         appKey:@"562470dde0f55abc20004f31"
                                      shareText:@"你要分享的文字"
                                     shareImage:[UIImage imageNamed:@"icon.png"]
                                shareToSnsNames:[NSArray arrayWithObjects:UMShareToSina,UMShareToWechatSession,UMShareToWechatTimeline,UMShareToWechatFavorite,UMShareToQQ,nil]
                                       delegate:self];

}



- (IBAction)wechat:(id)sender {
//    [UMSocialSnsService presentSnsIconSheetView:self
//                                         appKey:@"562470dde0f55abc20004f31"
//                                      shareText:@"友盟社会化分享让您快速实现分享等社会化功能，www.umeng.com/social"
//                                     shareImage:[UIImage imageNamed:@"blackArrow.png"]
//                                shareToSnsNames:@[UMShareToWechatSession,UMShareToWechatTimeline,UMShareToWechatFavorite]
//                                       delegate:self];

    
    
    //使用UMShareToWechatSession,UMShareToWechatTimeline,UMShareToWechatFavorite分别代表微信好友、微信朋友圈、微信收藏
    
    
    [[UMSocialDataService defaultDataService]  postSNSWithTypes:@[UMShareToWechatTimeline] content:@"分享内嵌文字" image:[UIImage imageNamed:@"blackArrow"] location:nil urlResource:nil presentedController:self completion:^(UMSocialResponseEntity *response){
        if (response.responseCode == UMSResponseCodeSuccess) {
            NSLog(@"分享成功！%@",response);
        }
    }];
    
    
    
    [UMSocialData defaultData].extConfig.wechatTimelineData.url = @"http://dev.umeng.com/social/ios/detail-share#2";
//    [UMSocialData defaultData].extConfig.wxMessageType = UMSocialWXMessageTypeText;
    [UMSocialData defaultData].extConfig.wechatTimelineData.title = @"微信朋友圈title";



    
    
}
    //实现回调方法（可选）：
    -(void)didFinishGetUMSocialDataInViewController:(UMSocialResponseEntity *)response
    {
        
        //根据`responseCode`得到发送结果,如果分享成功
        if(response.responseCode == UMSResponseCodeSuccess)
        {
            //得到分享到的微博平台名
            NSLog(@"share to sns name is %@",[[response.data allKeys] objectAtIndex:0]);
        }
    }







@end
